package com.cdtye.itps.cms.service.deduction;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cdtye.common.mybatiscore.base.BaseService;
import com.cdtye.itps.cms.dao.deduction.entity.JcjcKmDeduction;
import com.cdtye.itps.cms.dao.deduction.vo.JcjcKmDeductionVo;
import com.cdtye.itps.cms.mapper.deduction.JcjcKmDeductionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * 公里扣分项记录表 服务类
 * @author Jchen
 * @date 2021-09-24
 */
@Service
public class JcjcKmDeductionService extends BaseService<JcjcKmDeductionMapper, JcjcKmDeduction> {

    @Autowired
    private JcjcKmDeductionMapper modelMapper;

    /**
     * 分页查询，自定义sql语句
     * @param vo
     * @return
     */
    public IPage<Map<String,Object>> listPage(JcjcKmDeductionVo vo){
        return modelMapper.list(vo.page(), vo);
    }

    public JcjcKmDeduction queryByParams(String lineId, String directionId, Date taskDate, String mileage){
        QueryWrapper<JcjcKmDeduction> wrapper = new QueryWrapper<>();
        wrapper.eq("line_id",lineId);
        wrapper.eq("direction_id",directionId);
        wrapper.eq("task_date",taskDate);
        wrapper.eq("mileage",mileage);
        return modelMapper.selectOne(wrapper);
    }
}
